<?php

/**
 * This is the model class for table "tbl_artist".
 *
 * The followings are the available columns in table 'tbl_artist':
 * @property integer $row_id
 * @property string $id_code
 * @property string $l_name
 * @property string $f_name
 * @property string $m_names
 * @property string $st_addr
 * @property string $room
 * @property string $po_box
 * @property string $city
 * @property string $us_state
 * @property string $zip
 * @property string $office_ph
 * @property string $home_ph
 * @property string $cell_ph
 * @property string $email
 * @property integer $is_active
 */
class Artist extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Artist the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_artist';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_code, l_name, f_name', 'required'),
			array('is_active', 'numerical', 'integerOnly'=>true),
			array('id_code, l_name, f_name, m_names, st_addr, room, po_box, city, email', 'length', 'max'=>55),
			array('us_state', 'length', 'max'=>2),
			array('zip', 'length', 'max'=>5),
			array('office_ph, home_ph, cell_ph', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('row_id, id_code, l_name, f_name, m_names, st_addr, room, po_box, city, us_state, zip, office_ph, home_ph, cell_ph, email, is_active', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'row_id' => 'Row',
			'id_code' => 'Account Number',
			'l_name' => 'Last Name',
			'f_name' => 'First Name',
			'm_names' => 'Middle Name',
			'st_addr' => 'Street Address',
			'room' => 'Suite Number',
			'po_box' => 'PO Box',
			'city' => 'City',
			'us_state' => 'State',
			'zip' => 'Zip',
			'office_ph' => 'Office Phone Number',
			'home_ph' => 'Home Phone Number',
			'cell_ph' => 'Cell Phone Number',
			'email' => 'Email',
			'is_active' => 'Active?',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('row_id',$this->row_id);
		$criteria->compare('id_code',$this->id_code,true);
		$criteria->compare('l_name',$this->l_name,true);
		$criteria->compare('f_name',$this->f_name,true);
		$criteria->compare('m_names',$this->m_names,true);
		$criteria->compare('st_addr',$this->st_addr,true);
		$criteria->compare('room',$this->room,true);
		$criteria->compare('po_box',$this->po_box,true);
		$criteria->compare('city',$this->city,true);
		$criteria->compare('us_state',$this->us_state,true);
		$criteria->compare('zip',$this->zip,true);
		$criteria->compare('office_ph',$this->office_ph,true);
		$criteria->compare('home_ph',$this->home_ph,true);
		$criteria->compare('cell_ph',$this->cell_ph,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('is_active',$this->is_active);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}